{# SPDX-FileCopyrightText: © 2015 Siemens AG

   SPDX-License-Identifier: FSFAP
#}
<spdx:hasFile>
  <spdx:File rdf:about="#SPDXRef-item{{ fileId|url_encode }}">
    <spdx:fileName>{{ fileName|e }}</spdx:fileName>
    <spdx:checksum>
      <spdx:Checksum>
        <spdx:algorithm rdf:resource="http://spdx.org/rdf/terms#checksumAlgorithm_sha1" />
        <spdx:checksumValue>{{ sha1 | lower }}</spdx:checksumValue>
      </spdx:Checksum>
    </spdx:checksum>
    <spdx:checksum>
      <spdx:Checksum>
        <spdx:algorithm rdf:resource="http://spdx.org/rdf/terms#checksumAlgorithm_sha256" />
        <spdx:checksumValue>{{ sha256 | lower }}</spdx:checksumValue>
      </spdx:Checksum>
    </spdx:checksum>
    <spdx:checksum>
      <spdx:Checksum>
        <spdx:algorithm rdf:resource="http://spdx.org/rdf/terms#checksumAlgorithm_md5" />
        <spdx:checksumValue>{{ md5 | lower }}</spdx:checksumValue>
      </spdx:Checksum>
    </spdx:checksum>
{%~ if isCleared %}
  {%~ if concludedLicenses|default is empty %}
    <spdx:licenseConcluded rdf:resource="http://spdx.org/rdf/terms#none" />
  {%~ elseif concludedLicenses|length > 1 %}
    <spdx:licenseConcluded>
    {%~ if 'Dual-license' in concludedLicenses and concludedLicenses|length > 2 %}
      <spdx:DisjunctiveLicenseSet>
    {%~ else %}
      <spdx:ConjunctiveLicenseSet>
    {%~ endif %}{# End dual license check #}
    {%~ for res in concludedLicenses %}
      {%~ if res starts with 'LicenseRef-' %}
        <spdx:member rdf:resource="#{{ res|replace({' ': '-'})|url_encode }}" />
      {%~ else %}
        {%~ if licenseInfoConcluded[res] is defined %}{# License defined first time #}
        <spdx:member>
          <spdx:ListedLicense rdf:about="http://spdx.org/licenses/{{ licenseInfoConcluded[res].id|replace({' ': '-'})|url_encode }}">
            <spdx:name>{{ licenseInfoConcluded[res].name|e }}</spdx:name>
            <spdx:licenseId>{{ licenseInfoConcluded[res].id|replace({' ': '-'})|e }}</spdx:licenseId>
            <spdx:licenseText><![CDATA[
{{ licenseInfoConcluded[res].text|replace({'\f':''})
                                 |replace({']]>':']]]]><![CDATA[>'}) }}
            ]]></spdx:licenseText>
          {%~ if licenseInfoConcluded[res].url is not empty %}
            <rdfs:seeAlso>{{ licenseInfoConcluded[res].url }}</rdfs:seeAlso>
          {%~ endif %}
          </spdx:ListedLicense>
        </spdx:member>
        {%~ else %}
        <spdx:member rdf:resource="http://spdx.org/licenses/{{ res|replace({' ': '-'})|url_encode }}" />
        {%~ endif %}
      {%~ endif %}{# End printing license conclusion #}
    {%~ endfor %}
    {%~ if 'Dual-license' in concludedLicenses and concludedLicenses|length > 2 %}
      </spdx:DisjunctiveLicenseSet>
    {%~ else %}
      </spdx:ConjunctiveLicenseSet>
    {%~ endif %}
    </spdx:licenseConcluded>
  {%~ elseif concludedLicenses|length == 1 %}
    {%- set res = concludedLicenses[0] %}
    {%- if res starts with 'LicenseRef-' %}
    <spdx:licenseConcluded rdf:resource="#{{ res|replace({' ': '-'})|url_encode }}" />
    {%~ else %}
      {%~ if licenseInfoConcluded[res] is defined %}{# License defined first time #}
    <spdx:licenseConcluded>
      <spdx:ListedLicense rdf:about="http://spdx.org/licenses/{{ licenseInfoConcluded[res].id|replace({' ': '-'})|url_encode }}">
        <spdx:name>{{ licenseInfoConcluded[res].name|e }}</spdx:name>
        <spdx:licenseId>{{ licenseInfoConcluded[res].id|replace({' ': '-'})|e }}</spdx:licenseId>
        <spdx:licenseText><![CDATA[
{{ licenseInfoConcluded[res].text|replace({'\f':''})
          |replace({']]>':']]]]><![CDATA[>'}) }}
        ]]></spdx:licenseText>
        {%~ if licenseInfoConcluded[res].url is not empty %}
        <rdfs:seeAlso>{{ licenseInfoConcluded[res].url }}</rdfs:seeAlso>
        {%~ endif %}
      </spdx:ListedLicense>
    </spdx:licenseConcluded>
      {%~ else %}
    <spdx:licenseConcluded rdf:resource="http://spdx.org/licenses/{{ res|replace({' ': '-'})|url_encode }}" />
      {%~ endif %}
    {%~ endif %}{# End printing single conclusion #}
  {%~ endif %}
{%~ else %}
    <spdx:licenseConcluded rdf:resource="http://spdx.org/rdf/terms#noassertion" />
{%~ endif %}{# End license conclusion block #}
{%~ if licenseCommentState %}{# License comments to be printed #}
  {%~ if licenseComment is empty %}
    <spdx:licenseComments rdf:resource="http://spdx.org/rdf/terms#noassertion" />
  {%~ else %}
    <spdx:licenseComments><![CDATA[{{ licenseComment|e }}]]></spdx:licenseComments>
  {%~ endif %}
{% endif %}
{%~ if scannerLicenses|default is empty %}
    <spdx:licenseInfoInFile rdf:resource="http://spdx.org/rdf/terms#noassertion" />
{%~ else %}
  {%~ for res in scannerLicenses %}
    {%~ if res starts with 'LicenseRef-' %}
    <spdx:licenseInfoInFile rdf:resource="#{{ res|replace({' ': '-'})|url_encode }}" />
    {%~ else %}
      {%~ if licenseInfoScanner[res] is defined %}{# License defined first time #}
    <spdx:licenseInfoInFile>
      <spdx:ListedLicense rdf:about="http://spdx.org/licenses/{{ licenseInfoScanner[res].id|replace({' ': '-'})|url_encode }}">
        <spdx:name>{{ licenseInfoScanner[res].name|e }}</spdx:name>
        <spdx:licenseId>{{ licenseInfoScanner[res].id|replace({' ': '-'})|e }}</spdx:licenseId>
        <spdx:licenseText><![CDATA[
{{ licenseInfoScanner[res].text|replace({'\f':''})
                              |replace({']]>':']]]]><![CDATA[>'}) }}
        ]]></spdx:licenseText>
        {%~ if licenseInfoScanner[res].url is not empty %}
        <rdfs:seeAlso>{{ licenseInfoScanner[res].url }}</rdfs:seeAlso>
        {%~ endif %}
      </spdx:ListedLicense>
    </spdx:licenseInfoInFile>
      {%~ else %}
    <spdx:licenseInfoInFile>
      <spdx:ListedLicense rdf:about="http://spdx.org/licenses/{{ res|replace({' ': '-'})|url_encode }}" />
    </spdx:licenseInfoInFile>
      {%~ endif %}
    {%- endif %}
  {%- endfor %}{# End printing license infos in file #}
{%- endif %}
{%~ if copyrights|default is empty %}
    <spdx:copyrightText rdf:resource="http://spdx.org/rdf/terms#noassertion" />
{%~ else %}
    <spdx:copyrightText><![CDATA[
  {%~ for cp in copyrights %}
      {{ cp|replace({'\f':''})
           |replace({']]>':']]]]><![CDATA[>'}) }}
  {%~ endfor %}
    ]]></spdx:copyrightText>
{%~ endif %}
{%~ for ack in acknowledgements %}
    <spdx:attributionText><![CDATA[{{ ack|replace({'\f':''})
            |replace({']]>':']]]]><![CDATA[>'}) }}]]></spdx:attributionText>
{%~ endfor %}
  </spdx:File>
</spdx:hasFile>
